This example reads data from the FastCCD and corrects and rotates the images. Included are some example of widgets to interact with the data
Load the databroker moudle, csxtools and various other dependencies
import numpy as np
from databroker import DataBroker, get_table
from csxtools.utils import get_fastccd_images, get_images_to_4D
from csxtools.ipynb import image_stack_to_movie, show_image_stack
%matplotlib inline
from matplotlib import pyplot as plt
Set the logger level to info to see logging output
import logging
logging.getLogger().setLevel(logging.INFO)
bgnd = DataBroker['ce5042b7-00ae-49ca-9b11-b10c5661aaaa'] #[52440]
data = DataBroker['b2596f8e-d220-4aea-8a55-8ccb17cbdacc'] #[52436]
Now correct the CCD images, using only a single background image.
In the future this should be taken from the metadata associated with the data, or from the darkfield entry
First lets just look at the background stack as a "lightfield"
images = get_fastccd_images(data, (bgnd, None, None), tag='fccd_image_lightfield')
The returned images object is a 4D stack of images of shape (N, M, y, x) where N is the number of events. This is - for example - the number of data points in a scan. M is the number of images collected at each point, while y and x are the size of the CCD chip.
As the data was collected as a single ct(), there is only one event. Lets select that.
stack = images[0]
stack[0]
We can use this as a PIMS object, or we could convert it to a image stack using the get_images_to_4D() function
arr = get_images_to_4D(stack)
arr.shape
type(arr)
arr[0] # The first image, corrected
We can, however use the pims object in most functions to look at the data. There are a couple of nice interactive objects which can be used to look at image stacks.
show_image_stack(stack, (-100, 100))
This produces an HTML5 movie which can be viewed in most browsers
image_stack_to_movie(stack[20:120], figsize=(12, 10), vmin=-20, vmax=20)